<?php


namespace App\Repositories;


use App\Models\Banner;
use App\Models\Team;
use Illuminate\Support\Facades\Cache;
class TeamRepository extends Repository
{
    protected $modelClass = Team::class;

    public function get($is_cache=true){

        if (Cache::has(config('global.cache.team')) && $is_cache){
            $teams = Cache::get(config('global.cache.team'));
        }else{
            $teams = $this->model()->with('products')->where('status',1)->orderBy('sort')->get();
            Cache::set(config('global.cache.team'),$teams);
        }

        return $teams;
    }

    public function find($id){
        return $this->get()->firstWhere('id',$id);
    }



}
